<?php
declare (strict_types=1);

namespace app\api\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class Spec extends Model
{
    public $table = 'pyg_spec';
    protected $pk = 'id';

    /**
     * 商品规格和商品规格值值得关联   一个商品规格拥有多种商品规格   一对多
     * @return \think\model\relation\HasMany
     */
    public function specValue()
    {
        return $this->hasMany(Spec_value::class, 'spec_id');
    }

    public static function delSpec($id)
    {
        return self::where('type_id', $id)->delete();
    }

    public static function getId($id)
    {
        return self::where('type_id', $id)->field('id')->find()->toArray();
    }
}
